import CONSTANT from '@/common/constants.js';
import http from '@/common/http.js';

export default {
  name: 'queryResult',
  components: {},
  data () {
    return {
      studentId: '',
      siteId: '',
      keyWords: '',
      status: '',
      reserveNo:'',
      applyFee:'',
      contents: {
        applyStatus:1
      }
    }
  },
  mounted () {
    var _this = this
    _this.studentId = window.sessionStorage.getItem('studentId')
    _this.siteId = '531B601029F97174012A0D3D396600B2'
    _this.reserveNo = this.$route.query.reserveNo
    _this.goList()
  },
  methods: {
    goList () {
      var _this = this
      http.get(CONSTANT.QUERYBYRESERVENO + '?siteId=' + _this.siteId + '&reserveNo=' + _this.reserveNo, {
      }, (res) => {
        if (res.classTimeable != undefined && res.classTimeable.indexOf('\r\n') > -1) {
          res.classTimeable = res.classTimeable.split('\r\n')
       }
         _this.contents = res
        _this.applyFee = res.applyFee
      //alert(JSON.stringify(res))
    })
    },
    comeBack () {
      window.history.go(-1)
    },
    goPayment: function (id) {
      if (this.contents.isPayable) {
        http.post(CONSTANT.CLAZZVIEW, {
          siteId: this.siteId,
          id: id,
          studentId: this.studentId
        }, (res) => {
          this.content = res
          var query = {reserveNo:this.reserveNo,name:this.content.name,totalFees:this.applyFee,area:this.content.area,classNo:this.content.classNo,frontStatusName:this.content.frontStatusName,year:this.content.year,term:this.content.term,spelName:this.content.spelName,degree:this.content.degree,studentName:this.contents.studentName}
          this.$router.push({path: '/payment',query:query})
        })
      }
    }
  }
}
